import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'appVue',
        component: () => import('../testVue/index.vue'),
        // redirect: 'grid',

        // beforeEnter: (to, form, next) => {
        //   console.log('to==', to);
        //   console.log('form==', form);
        //   if (null != sessionStorage.getItem('token')) {
        //     next('/workContent')
        //   } else {
        //     next('/login')
        //   }
        // },
        // redirect: 'login',
        children: [
            {
                path: 'grid',
                name: 'gridVue',
                component: () => import('../testVue/gridVue/index.vue')
            },
            {
                path: 'table',
                name: 'tableVue',
                component: () => import('../testVue/tableVue/index.vue')
            },
            {
                path: 'websocket',
                name: 'websocketVue',
                component: () => import('../testVue/websocket/index.vue')
            },
        ]
    },
]

// // 获取原型对象push函数
// const originalPush = VueRouter.prototype.push

// // 获取原型对象replace函数
// const originalReplace = VueRouter.prototype.replace

// // 修改原型对象中的push函数
// VueRouter.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch(err => err)
// }

// // 修改原型对象中的replace函数
// VueRouter.prototype.replace = function replace(location) {
//   return originalReplace.call(this, location).catch(err => err)
// }


const router = new VueRouter({
    routes
})

export default router
